import { api } from './request'

/**
 * 菜单管理相关API接口
 */
export const menuApi = {
  /**
   * 获取菜单树
   */
  getMenuTree: () => {
    return api.get('/menu/tree')
  },

  /**
   * 获取菜单列表
   * @param params 查询参数
   */
  getMenuList: (params: {
    page: number
    pageSize: number
    name?: string
    visible?: number
  }) => {
    return api.get('/menu/list', params)
  },

  /**
   * 添加菜单
   * @param data 菜单数据
   */
  addMenu: (data: {
    parentId: number
    name: string
    path: string
    component?: string
    icon?: string
    type: number
    permission?: string
    visible: number
    status: number
    sort: number
  }) => {
    return api.post('/menu/add', data)
  },

  /**
   * 编辑菜单
   * @param data 菜单数据
   */
  updateMenu: (data: {
    id: number
    parentId: number
    name: string
    path: string
    component?: string
    icon?: string
    type: number
    permission?: string
    visible: number
    status: number
    sort: number
  }) => {
    return api.put('/menu/update', data)
  },

  /**
   * 删除菜单
   * @param id 菜单ID
   */
  deleteMenu: (id: number) => {
    return api.delete(`/menu/delete/${id}`)
  }
}